<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>咨询管理</title>
<link rel="stylesheet" href="css/css_resetA.css">
<link type="text/css" rel="stylesheet" href="css/consult_detailA.css" />
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="js/jquery.md5A.js"></script>
<script type="text/javascript" src="js/jquery.jsonpA.js"></script>

<script type="text/javascript" src="js/jquery.cookieA.js"></script>
<script type="text/javascript" src="js/pupil-ajaxA.js"></script>
<script type="text/javascript" src="js/bA.js"></script>
<script type="text/javascript" src="js/styleA.js"></script>
</head>

<body>
	<div class="public-top min-cen">
    	<div class="center logo"></div>
    </div>
    <div class="containter">
        <div class="intr">
            <!--介绍部分-->
            <div class="left">
                <h3 class="createTime"><b>创建时间：</b><span>更新时间：</span></h3>
                <div class="text">
                    <div class="title">
                        <b></b>
                        <h3 class="detail"><b>咨询详情</b><span></span></h3>
                    </div>
                    <div class="content">
                        <p></p>
                    </div>
                </div>
            </div>
            <!--头像-->
            <div class="right">
                <div class="img">
                    <div class="headImg">
                        <img src="images/admin/pic.jpg" alt="">
                        <p>可爱的柠檬</p>
                    </div>
                    <div class="info">
                        <ul>
                            <li>年龄:<b></b></li>
                            <li>性别:<b></b></li>
                            <li>地区:<b></b></li>
                        </ul>
                    </div>
                </div>
                <div class="remarks">
                    <h3><span>备注：</span></h3>
                    <textarea name="beizhu" id="beizhu" style="height: 47px;line-height: 20px;width: 98%;"></textarea>
                    <div class="confim_btn">
                        <button>确认</button>
                    </div>
                </div>
            </div>
        </div>
        <!--回复内容部分-->
        <div class="replyContent">

        </div>
        <!--发送-->
        <div class="send">
            <div class="mySend">
                <img src="images/admin/pic.jpg" alt="">
            </div>
            <div class="sendText">
                <div id="sendText" >
                    <textarea name="text" cols="30" rows="10"></textarea>
                    <b>最多30个字</b>
                </div>
                <div>
                    <p><span>按下ctrl+enter换行</span><a href="#" class="sendBtn">发送</a></p>
                </div>
            </div>
        </div>
    </div>
    <div style="height:300px">
    </div>
    <input type="hidden" id="consultId">
</body>
<script src="js/jquery-min.js"></script>
<script>
    getReply();
    function pi(el){
        return parseInt(el);
    }
    function checkP(){
        $(".replyContent .item .text p").each(function(){
            if(pi($(this).css("height"))>pi($(this).css("line-height"))){
                if($(this).parent().parent().hasClass("imgRight")){
                    $(this).css({
                        "text-align":"left"
                    });
                }
            }else{
                $(this).css({
                    "text-align":"right",
                    "height":$(this).siblings("img").css("height"),
                    "line-height":$(this).siblings("img").css("height")
                });
            }
        });
    }
    checkP();
//    发送按钮调用回复接口
    $(".sendBtn").click(function(event){
        event.preventDefault();
        var content=$("#sendText>textarea").val().trim();
        alert(content.length);
        if(content.length>30){
            alert("回复字数最多30字");
            return false;
        }
        if(content){
            ajaxPostJson(requestUrl + "/AddConsultDetailServlet4M", function(data, status){
                eval("rt=" + data);
                if(rt.error!==""){
                    alert(rt.error);
                }else{
                    $("#sendText>textarea").val("");
                    getReply();
                }
            }, {"from":"expert","consultId":getQueryString("consultId") ,"content":content,"debug":1,"expertId":"1"});
        }else{
            alert("回复内容不能为空...");
        }
    });
    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }
    function getReply(){
        ajaxPostJson(requestUrl + "/ShowConsultServlet4M", function(data, status){
            eval("rt=" + data);
            if(rt.error!==""){
                alert(rt.error);
            }else{
                var ques=rt.consult;
                $(".left .detail>span").html(ques.tag);
                $(".headImg>img").attr('src',ques.user_headimg);
                $('.left .content>p').html(ques.description);
                $(".info>ul>li:first-child>b").html(ques.age);
                $(".info>ul>li:nth-child(2)>b").html(ques.gender);
                $(".info>ul>li:nth-child(3)>b").html(ques.user_city);
                $(".createTime>b").html('创建时间：'+ques.commitTime.slice(0,-2));
                $(".createTime>span").html('更新时间：'+ques.operateTime.slice(0,-2));
                $(".remarks>p").html(rt.note);
                var str='';
                for(var i=0;i<rt.detailList.length;i++){
                    var list=rt.detailList[i];
                    var arrow='imgRight';
                    if(list.user_nickname=='柠檬心理'){
                        arrow='imgLeft';
                    }
                    str+='<div class="item '+arrow+'">\
                    <div class="title">'+list.recordTime.slice(0,-2)+'</div>\
                    <div class="text">\
                            <img src="'+list.user_headimg+'" alt="">\
                            <p>'+list.content+'</p>\
                      </div>\
                     </div>';
                }
                $(".replyContent").html(str);
            }
        }, {"from":"expert","consultId":getQueryString("consultId"),"debug":1,"expertId":1});
    }
</script>
</html>
